#!/bin/bash

if [ `whoami` != "root" ]
then
	echo "You must be root"
	exit
fi

# remove old package
rm -fr deb *.deb

# create package structure
mkdir -p deb/usr/bin
mkdir deb/DEBIAN

echo "Package: OpenDomo
Priority: optional
Section: misc
Maintainer: dlerch@gmail.com
Architecture: all
Version: 1.0
Depends:
Description: OpenDomo Package Collection" > deb/DEBIAN/control

# odcontrol
cd opendomo-control
make gcc=1
cd ..
cp -fr opendomo-control/etc deb/
cp -fr opendomo-control/var deb/
cp -fr opendomo-control/usr deb/

# odcgi
cd opendomo-cgi
make gcc=1
cd ..
cp -fr opendomo-cgi/etc deb/
cp -fr opendomo-cgi/var deb/
cp -fr opendomo-cgi/usr deb/
mv deb/var/www/cgi-bin/* /usr/lib/cgi-bin/ 



# oddicovery
cd opendomo-discovery
make gcc=1
cd ..
cp -fr opendomo-discovery/etc deb/
cp -fr opendomo-discovery/var deb/
cp -fr opendomo-discovery/usr deb/discovery

# create package
chown -R root.root deb
dpkg -b deb opendomo-0.8.6.deb



